package cn.tedu.sp04.order.feignclient;

import cn.tedu.sp01.pojo.User;
import cn.tedu.web.util.JsonResult;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFB implements UserFeignClient{


    @Override
    public JsonResult<User> getUser(Integer userId) {
        //有60%的可能，会执行成功，将结果返回
        if(Math.random()<0.4){
            User user = new User(userId,"user缓存中的name"+userId,"user缓存中的pwd"+userId);

            return JsonResult.ok().data(user);
        }

        return JsonResult.err().msg("获取user信息失败！");
    }

    @Override
    public JsonResult addScore(Integer userId, Integer score) {

        //100%失败

        return JsonResult.err().msg("无法给这个user增加这些score！");
    }
}
